home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / Late Breaking / Changes #1 next >
Encoding:
Text File  |  1996-05-01  |  3.7 KB  |  120 lines  |  [TEXT/MPS ]

  1. After E.T.O. #20 was buttoned up we found a couple of problems in the Framework library
  2. of MacApp.  These problems involve two member functions of TDispatcher.  To make the
  3. change to the source file open the file:
  4.  
  5.     Target "{macapp}Libraries:Framework:Sources:UDispatcher.cp"
  6.  
  7. The two functions to be replaced are:
  8.  
  9.     TDispatcher::GetDocumentByIndex
  10.     TDispatcher::GetContainedObject
  11.  
  12. You should be able to find the first routine by executing the following MPW script:
  13.  
  14.     find •
  15.     find /TDocument∂* TDispatcher::GetDocumentByIndex/
  16.     find /∂{/
  17.     matchit -c -h
  18.     find §:/∂n/:\TDocument∂* TDispatcher::GetDocumentByIndex\
  19.  
  20. You can then replace the selected code with the replacement code provided below.
  21.  
  22. To find the second routine by executing the following MPW script:
  23.  
  24.     find •
  25.     find /MScriptableObject∂* TDispatcher::GetContainedObject/
  26.     find /∂{/
  27.     matchit -c -h
  28.     find §:/∂n/:\MScriptableObject∂* TDispatcher::GetContainedObject\
  29.  
  30. You can then replace the selected code with the other replacement code provided below.
  31.  
  32. //----------------------------------------------------------------------------------------
  33. // TDispatcher::GetDocumentByIndex: 
  34. //----------------------------------------------------------------------------------------
  35. #pragma segment MAScriptingRes
  36.  
  37. TDocument* TDispatcher::GetDocumentByIndex(DescType desiredType,
  38.                                            short desiredIndex)
  39. {
  40.     // Go through the window list and count to the Nth window associated with a document
  41.     // of the desired type.  Only count the first window for each document just
  42.     // in case a document has more than one window.
  43.  
  44.     TWindow*    aWindow = GetFrontWindow();
  45.     TDocument*    aDocument = NULL;
  46.     short        documentsSeen = 0;
  47.     if (aWindow)
  48.     {
  49.         // Make a list for all of the documents we find until we find the one we want.
  50.         TList*        aDocList = ::NewList();
  51.         WindowRef    aWindowRef = aWindow->fWMgrWindow;
  52.  
  53.         while (aWindowRef && (documentsSeen < desiredIndex))
  54.         {
  55.             aWindow = WMgrToWindow(aWindowRef);
  56.             if (aWindow)
  57.             {
  58.                 aDocument = aWindow->fDocument;
  59.                 if (aDocument && (aDocument->GetOMClass() == desiredType))
  60.                 {
  61.                     // See if this document is already in the list.
  62.                     if (!aDocList->GetIdentityItemNo(aDocument))
  63.                     {
  64.                         ++documentsSeen;
  65.                         aDocList->InsertLast(aDocument);
  66.                     }
  67.                 }
  68.             }
  69.             aWindowRef = GetNextWindow(aWindowRef);
  70.         }
  71.         aDocList->Free();
  72.     }
  73.     return (documentsSeen == desiredIndex) ? aDocument : NULL;
  74. }
  75.  
  76. //----------------------------------------------------------------------------------------
  77. // TDispatcher::GetContainedObject: 
  78. //----------------------------------------------------------------------------------------
  79. #pragma segment OSLDispatchRes
  80.  
  81. MScriptableObject* TDispatcher::GetContainedObject(DescType desiredType,
  82.                                                    DescType selectionForm,
  83.                                                    const CAEDesc& selectionData)
  84. {
  85.     MScriptableObject * result = NULL;
  86.  
  87.     if (desiredType == cFile)
  88.     {
  89.         // When you script 'file "Macintosh HD:My File"' AppleScript will
  90.         // give the app a pathname and expect a file object in return.
  91.         TFile * resultFile = DoMakeFile(cOpen);
  92.         CStr255 thePathName;
  93.         selectionData.GetString(thePathName);
  94.         resultFile->SpecifyWithTrio(0, 0, (CStr63 &)thePathName);
  95.         TOSADispatcher::fgDispatcher->AddTemporaryToken(resultFile);
  96.  
  97.         result = resultFile;
  98.     }
  99.     else if (IsDocumentClass(desiredType) && selectionForm == formName)
  100.     {
  101.         // We know we're going after a document with a 
  102.         // specific name so just scan the document list.
  103.         CStr255 theDocName;
  104.         selectionData.GetString(theDocName);
  105.  
  106.         CNoGhostDocsIterator iter(this);
  107.         while (TDocument * aDocument = iter++)
  108.             if ((aDocument->GetOMClass() == desiredType) && (aDocument->fTitle == theDocName))
  109.             {
  110.                 result = aDocument;
  111.                 break;
  112.             }
  113.     }
  114.     else
  115.         result = MScriptableObject::GetContainedObject(desiredType, selectionForm, selectionData);
  116.  
  117.     return result;
  118. }
  119.  
  120.